package priv.pront.code.robot.robCom_pri_2022;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;

/**
 * @Description:
 * @Author: pront
 * @Time:2023-06-30 20:23
 */
public class RC_v6_拼瓷砖 {

    static BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
    static char[][] g;
    static int n, m, N = 1010, cnt = 0;
    static Range[] range = new Range[1010];
    static Map<Character, Integer> PCI = new HashMap<>();
    //        struct Range {
//            char c;
//            int s;
//            int am;
//            bool operator<(const Range & t) const{
//                if (c == t.c) {
//                    return s < t.s;
//                }
//                return c < t.c;
//            }
//        } range[1010];


    static class Range {
        public char c;
        public int s;
        public int am;
    }

    static class Com implements Comparator<Range> {
        @Override
        public int compare(Range o1, Range o2) {
            if (o1.c == o2.c) {
                return o1.s - o2.s;
            }
            return o1.c - o2.c;
        }
    }

    public static void main(String[] args) throws IOException {
        g = new char[N][N];
        String[] s = bf.readLine().split(" ");
        n = Integer.parseInt(s[0]);
        m = Integer.parseInt(s[1]);
        for (int i = 1; i <= n; i++) {
            g[i] = bf.readLine().toCharArray();
        }
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                if (g[i][j] == '*')
                    continue;
                int l = 1, r = Math.min(n, m);
                while (l < r) {
                    int mid = (l + r + 1) / 2;
                    if (check(mid, i, j)) {
                        l = mid;
                    } else {
                        r = mid - 1;
                    }
                }
                boolean flag = false;
                for (int k = 0; k < cnt; k++) {
                    if (range[k].c == g[i][j] && range[k].s == l) {
                        range[k].am++;
                        flag = true;
                        break;
                    }
                }
                if (!flag) {
                    range[cnt].c = g[i][j];
                    range[cnt].s = l;
                    range[cnt].am = 1;
                    cnt++;
                }
                for (int x = i; x < i + l; x++) {
                    for (int y = j; y < j + l; y++) {
                        g[x][y] = '*';
                    }
                }
            }
            Arrays.sort(range, new Com());
            System.out.println(cnt);
            for (int j = 0; j < cnt; j++) {
                System.out.println( "color = " + range[j].c + "; size = " + range[j].s + "; amount = " + range[j].am);
            }
        }
    }

    public static boolean check(int mid, int x, int y) {
        char t = g[x][y];
        for (int i = x; i < x + mid; i++) {
            for (int j = y; j < y + mid; j++) {
                if (!(i >= 1 && i <= n && j >= 1 && j <= m && g[i][j] == t))
                    return false;
            }
        }
        return true;
    }

}
